package edu.scut.autoProcessor.po;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import edu.scut.autoProcessor.util.AppManager;


public class FaultPo {
	
	private static final Log logger = LogFactory.getLog(FaultPo.class); 
	
	private static DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	private  int id;
	
	private int appID;
	
	private String hostIP;
	
	private String hostName;
	
	private String reason;
	
	private String type;
	
	private short process;
	
	private Date collectDate;
	
	public FaultPo(){}
	
	public FaultPo(int app_id, String host_ip, String host_name, String reason, String type, short process, Date collect_date){
		this.hostIP = host_ip;
		this.hostName = host_name;
		this.reason = reason;
		this.type = type;
		this.process =process;
		this.collectDate = collect_date;
		this.appID = app_id;
	}
	
	public void setId(int id){
		this.id = id;
	}
	
	public void setAppID(int app_id){
		appID = app_id;
	}
	
	public void setHostIP(String host_ip){
		hostIP = host_ip;
	}
	
	public void setHostName(String host_name){
		hostName = host_name;
	}
	
	public void setReason(String reason){
		this.reason = reason;
	}
	
	public void setType(String type){
		this.type = type;
	}
	
	public void setProcess(short process){
		this.process = process;
	}
	
	public void setCollectDate(Date collect_date){
		collectDate = collect_date;
	}
	
	public int getId(){
		return id;
	}
	
	public String getAppName(){
		return AppManager.getAppNameByID(appID);
	}
	
	public String getHostIP(){
		return hostIP;
	}
	
	public String getHostName(){
		return hostName;
	}
	
	public String getReason(){
		return reason;
	}
	
	public String getType(){
		return type;
	}
	
	public short getProcess(){
		return process;
	}
	
	public String getCollectDate(){
		try{
			return format.format(collectDate);
		}catch(Exception e){
			logger.error(e.getMessage());
			return null;
		}
	}
}
